import React from 'react'
import { Form,Select } from 'antd'
import { formLayout } from '@/utils/utils'


const EditorForm = props => {
  const { form, record, cameraList, handleSelct, handleMacAdress } = props
  const { getFieldDecorator } = form
  return (
    <Form layout={formLayout}>
      <Form.Item label="所属商户" labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}>
        {getFieldDecorator('macName', {
          initialValue: record && record[0].macName,
        })(
          <Select disabled></Select>,
        )}
      </Form.Item>
      <Form.Item label="选择门店" labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}>
        {getFieldDecorator('storeName', {
          initialValue: record && record[0].storeName,
        })(
          <Select disabled></Select>,
        )}
      </Form.Item>
      <Form.Item label="MAC数据" labelCol={{ span: 4 }} wrapperCol={{ span: 20 }}>
        {getFieldDecorator('macAddress', {
          initialValue: record && record[0].macAddress,
        })(
          <Select onChange={val => handleMacAdress(val)}  onSelect={(macAddress, deviceName) => handleSelct(macAddress, deviceName)}>
            {cameraList && cameraList.map((r, index) => <Select.Option key={index} value={r.macAddress}>{r.deviceName}</Select.Option>)}
          </Select>,
        )}
      </Form.Item>
    </Form>
  )
}

export default Form.create({})(EditorForm)
